All Questions
Tagged with if-statementefficiency
2 questions
24votes
6answers
9kviews
Best practice for redundant conditions in if-elif-else statements
What is considered better practice? Case 1: if n == 0: doThis() elif n < 0: doThat() elif n > 0: doSomethingElse() Case 2: if n == 0: doThis() elif n < 0: doThat() else: ...
2votes
4answers
4kviews
Avoiding if statements in Nested FOR loops
Please pardon me if this is a duplicate question. I have two nested for loops which will iteration for around mn times (the complexity is around 3k). Inside these for loops, I have 3 If conditions ...